home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
025a
/
prgmchk.zip
/
QUOTECHK.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1991-07-21
|
4KB
|
117 lines
*(QUOTECHK.CMD - Quote checker routine -
This routine totals the number of quotation marks per line and prints
the line if the counts are odd: If the counts are odd but the line
ends with a + (the Rbase continuation symbol) then the routine skips
to the next line before comparing totals. The routine also skips full
comment lines,ie-lines beginning with -- or beginning with a *( and
ending with ). It also skips any line starting with SET QUO, ie-the
set quotes command.
created 19 July 91; Wm Driskell)
set mess off
set err mess off
set err var verr
set v blnk text = (char(32))
set v lastchar text = .blnk
set v oddchar = (char(254))
set quote = .oddchar *(oddchar=■)
set zero on
set v lineknt int = 0
CLS
WRITE ■Quotation Marks Checker■
WRITE ■-----------------------■
WRITE ■ ■
fillin ifile$ using ■Enter name of file to check: ■
fillin ofile$ using ■Enter name of file for output: ■
out .ofile$
write ■File: ■,.ifile$
write ■ ■
out scr
*( setup counters and constants )
set var fqknt int = 0, sqknt int = 0
set var fq$ = (CHAR(34)) *(double or full quote)
set var sq$ = (CHAR(39)) *(single quote)
set var ap = (char(254) + char(42) + char(40) +char(254)) *(comment chars)
set var lp = (char(254) + char(41) +char(254))
set var dd = (char(254) + char(45) + char(45) + char(254))
set var plus = (char(254) + char(43) + char(254))
*( load file into table as lines of text by temporarily changing the blank
character to fool the RBase ASCII-input-parsing routine )
drop cursor c1
drop tab t$$
write ■loading the data...■
create tab T$$ codeline text 100
set blank =.oddchar
load■t$$■from■.ifile$■as■ascii
set■blank=.blnk
WRITE ■ ■
WRITE ■Line #: total quote count, " and '■
write ■----------------------------------■
compute lk as rows from T$$
*( get line and parse for parentheses )
declare c1 cursor for select codeline from t$$
open c1
fetch c1 into a$ ind1
while sqlcode <> 100 then
set v lineknt = .lineknt + 1
write ■line■,.lineknt,■of■,.lk at 1 65 reverse
set v vslen = (slen(.a$))
if a$ not cont .fq$ and a$ not cont .sq$ then
GOTO skipline
endif
set v remchk = (sget(a$,2,1))
IF (lastchar <> .plus) AND ((remchk = .dd) OR +
(remchk = .ap AND sget(.a$,1,.vslen) = .lp)) THEN
GOTO skipline *( skip a full comment line )
ENDIF
set v vsloc = (sloc(.a$,■set qu■))
IF vsloc > 0 THEN
GOTO skipline *( skip a SET QUOTE statement )
ENDIF
set v l = (sloc(.a$, fq$))
set v r = (sloc(.a$, sq$))
set v b$ = .a$
while (.l + .r) > 0 then
IF l > 0 THEN
set v b$ = (sput(b$,■!■,.l))
set v fqknt = .fqknt + 1
ENDIF
IF r > 0 THEN
set v b$ = (sput(b$,■!■,.r))
set v sqknt = .sqknt + 1
ENDIF
set v l = (sloc(.b$, fq$))
set v r = (sloc(.b$, sq$))
endwhile
label skipline
set v lastchar = (sget(a$,1,.vslen)) *(check for continuation char)
IF (MOD(.fqknt,2) = 1 OR MOD(.sqknt,2) = 1) AND .lastchar <> ■+■ THEN
out scr with .ofile$ append
WRITE ■==>■,.lineknt,■: ■, .fqknt, .sqknt
WRITE .a$
out scr
ENDIF
fetch c1 into a$ ind1
endwhile
drop cursor c1
out scr with .ofile$ append
WRITE ■ ■
WRITE ■::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::■
WRITE ■ ■
WRITE ■total lines processed: ■,.lineknt
WRITE ■total number of quotes processed: ■
WRITE ■ " - ■,.fqknt
WRITE ■ ' - ■,.sqknt
WRITE ■ (ignoring full comment lines and SET QUOTE commands)■
WRITE ■::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::■
WRITE ■ ■
out scr
set quote='
drop tab t$$
clear var blnk,plus,lastchar,oddchar,lineknt,a$,b$,fqknt,sqknt,fq$,sq$,l,r+
vsloc,vslen,remchk,ofile$,ifile$,ind1,ap,lp,dd
return